﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.Composition;

namespace TfsGiggle.Core.Parsers
{
    /// <summary>
    /// Provides a factory that can provide an IParser instance for parsing .cs files
    /// </summary>
    [Export(typeof(IParserFactory))]
    class RoslynCSharpParserFactory : IParserFactory
    {
        public IParser GetParser(string fileExtension)
        {
            if (string.IsNullOrWhiteSpace(fileExtension))
            {
                return null;
            }
            if (fileExtension.EndsWith(".cs", StringComparison.InvariantCultureIgnoreCase))
            {
                return new RoslynCSharpParser();
            }
            return null;
        }

        /// <summary>
        /// Default to low priority
        /// </summary>
        public int Priority { get { return 0; } }
    }
}
